home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 028a / zip10ex.zip / IMPLODE.H < prev    next >
C/C++ Source or Header  |  1991-10-03  |  5KB  |  207 lines

  1. /*
  2.  
  3.  Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  4.  Permission is granted to any individual or institution to use, copy, or
  5.  redistribute this software so long as all of the original files are included
  6.  unmodified, that it is not sold for profit, and that this copyright notice
  7.  is retained.
  8.  
  9. */
  10.  
  11. /*
  12.  * implode.h by Richard B. Wales.
  13.  */
  14.  
  15. #include "crypt.h"
  16. #include "tempf.h"
  17. #include <errno.h>
  18.  
  19.  
  20. /***********************************************************************
  21.  *
  22.  * Type definitions.
  23.  */
  24.  
  25.  
  26. typedef long  L_INT;
  27. typedef int   INT;
  28. typedef short S_INT;
  29.  
  30. typedef unsigned long  UL_INT;
  31. typedef unsigned int   U_INT;
  32. typedef unsigned short US_INT;
  33.  
  34. typedef unsigned char  U_CHAR;
  35.  
  36. typedef unsigned long  CRC;
  37.  
  38. #define VOID void
  39.  
  40. #define local static            /* More meaningful outside functions */
  41. /* #define local */
  42.  
  43. #define TRUE  1
  44. #define FALSE 0
  45.  
  46. /* Error return codes. */
  47. typedef
  48. enum
  49.     {   IM_OK,                  /* all OK */
  50.         IM_EOF,                 /* end of file on input */
  51.         IM_IOERR,               /* I/O error */
  52.         IM_BADARG,              /* invalid procedure argument */
  53.         IM_NOMEM,               /* out of memory */
  54.         IM_LOGICERR,            /* logic error */
  55.         IM_NOCTBLS              /* no more code tables */
  56.     }
  57.     ImpErr;
  58.  
  59. /* The different possible compression methods. */
  60. typedef
  61. enum
  62.     {   NO_LITERAL_TREE,        /* use only two trees */
  63.         LITERAL_TREE            /* use all three trees */
  64.     }
  65.     Method;
  66.  
  67. /* File data structure. */
  68. typedef
  69. struct  fdata
  70.     {   L_INT    fd_len;        /* # of bytes in file */
  71.         L_INT    fd_clen;       /* compressed length */
  72.         tFILE    *fd_temp;      /* temporary file stream pointer */
  73.         U_INT    fd_bufsize;    /* size of sliding dictionary */
  74.         U_INT    fd_strsize;    /* max string match length */
  75.         U_INT    fd_nbits;      /* # distance bits to write literally */
  76.         Method   fd_method;     /* compression method */
  77.     }
  78.     FDATA;
  79.  
  80. /* Data structure for string matches. */
  81. typedef
  82. struct  match
  83.     {   S_INT       ma_dist;    /* distance back into buffer */
  84.         union {
  85.            US_INT   ma_length;  /* length of matched string */
  86.            U_CHAR   ma_litc[2]; /* literal characters matched */
  87.         } l;
  88.         /* l is ma_litc if ma_dist <= 0. If ma_dist < 0, the length is
  89.          * 2 and the distance is -ma_dist.
  90.          */
  91.     }
  92.     MATCH;
  93.  
  94.  
  95. /***********************************************************************
  96.  *
  97.  * External variable declarations.
  98.  */
  99.  
  100. extern FDATA fd;                /* file data */
  101. #ifndef MSDOS
  102. extern int errno;               /* system error code */
  103. #endif  /* MSDOS */
  104.  
  105. extern MATCH *ma_buf;           /* match info buffer */
  106. #define MA_BUFSIZE 512
  107. /* MA_BUFSIZE must be such that
  108.  *     256*sizeof(TRDATA) <= MA_BUFSIZE*sizeof(MATCH)
  109.  * since the same buffer is used for both purposes at different times.
  110.  */
  111.  
  112. /***********************************************************************
  113.  *
  114.  * External procedure declarations.
  115.  */
  116.  
  117.  
  118. #ifdef  MODERN
  119. #include <string.h>
  120. #else
  121. voidp *malloc();
  122. char  *strcpy();
  123. char  *strcat();
  124. #endif  /* MODERN */
  125.  
  126.  
  127. /***********************************************************************
  128.  *
  129.  * Routines in "im_lmat.c" source file.
  130.  */
  131.  
  132.  
  133. ImpErr  lm_init
  134.         OF ((int pack_level));
  135.  
  136. ImpErr  lm_input
  137.         OF ((U_CHAR *block, U_INT count));
  138.  
  139. ImpErr  lm_windup
  140.         OF ((void));
  141.  
  142.  
  143. /***********************************************************************
  144.  *
  145.  * Routines in "im_ctree.c" source file.
  146.  */
  147.  
  148. ImpErr ct_init
  149.         OF ((void));
  150.  
  151. ImpErr ct_tally
  152.         OF ((MATCH *ma));
  153.  
  154. ImpErr ct_mktrees
  155.         OF ((void));
  156.  
  157. ImpErr ct_wrtrees
  158.         OF ((FILE *outfp));
  159.  
  160. ImpErr ct_wrdata
  161.         OF ((FILE *outfp));
  162.  
  163. ImpErr ct_windup
  164.         OF ((void));
  165.  
  166.  
  167. /***********************************************************************
  168.  *
  169.  * Routines in "im_bits.c" source file.
  170.  */
  171.  
  172. ImpErr bi_init
  173.         OF ((FILE *fp));
  174.  
  175. ImpErr bi_rlout
  176.         OF ((int value, int length));
  177.  
  178. int bi_reverse
  179.         OF ((int value, int length));
  180.  
  181. ImpErr bi_windup
  182.         OF ((void));
  183.  
  184.  
  185. /***********************************************************************
  186.  *
  187.  * Routines in "implode.c" source file.
  188.  */
  189.  
  190. int imp_setup
  191.         OF ((long filesize, int pack_level));
  192.  
  193. int imp_p1
  194.         OF ((char *buf, int count));
  195.  
  196. int imp_size
  197.         OF ((long *size, char *opts));
  198.  
  199. int imp_p2
  200.         OF ((FILE *outfp));
  201.  
  202. int imp_clear
  203.         OF ((void));
  204.  
  205.  
  206. /**********************************************************************/
  207.